# author: axin
# date: 2021/4/21 19:41
# description:
from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response

from goods.models import SPUSpecification, SPU
from meiduo_admin.serialziers.specs import SpecsSerialzier, SPUSerializer
from meiduo_admin.utils import PageNum


class SpecsView(ModelViewSet):
    """
        商品规格的增删改查
    """
    queryset = SPUSpecification.objects.all()
    serializer_class = SpecsSerialzier
    # 使用分页器
    pagination_class = PageNum

    def simple(self, request):
        """
        获取SPU商品信息
        :param request:
        :return:
        """
        spus = SPU.objects.all()
        ser = SPUSerializer(spus, many=True)
        return Response(ser.data)
